<%@ Page Title="Edit Component" Language="C#" MasterPageFile="~/Pages/user/userMaster.Master" AutoEventWireup="true" CodeBehind="EditComponent.aspx.cs" Inherits="WarehouseWebAPP.Pages.user.Edit_Entities.EditComponent" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">

        .style13
        {
        width: 38px;
        height: 43px;
        background-color: #FFFFFF;
    }
        </style>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="style1" style="width: 101%; height: 322px;" bgcolor="White">
    <tr>
        <td valign="top" align="center">
                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                    <ContentTemplate>
                        <asp:Label ID="SentLabel" runat="server" BackColor="#FFFFCC" 
                    ForeColor="#607894" Text="Mail Sent" Visible="False"></asp:Label>
                    </ContentTemplate>
                </asp:UpdatePanel>
        </td>
    </tr>
    <tr>
        <td valign="top" align="center">
                <asp:UpdateProgress ID="UpdateProgress2" runat="server" DisplayAfter="1000">
                    <ProgressTemplate>
                        <img alt="" src="../../images/update.gif" style="width: 31px; height: 31px" />
                    </ProgressTemplate>
                </asp:UpdateProgress>
        </td>
    </tr>
    <tr>
        <td valign="top" >
            <asp:Panel ID="Panel1" runat="server" Height="34px">
                <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Italic="False" 
                    Font-Overline="False" Font-Underline="True" Text="Component Serial:" 
                ForeColor="#5D7B9D"></asp:Label>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <cc1:ComboBox ID="ComboBox1" runat="server" AppendDataBoundItems="True" 
                    AutoCompleteMode="Append" DataSourceID="comboObjectDataSource" 
                    DataTextField="component_serial_num" DataValueField="component_serial_num" 
                    DropDownStyle="DropDownList" MaxLength="0" style="display: inline;">
                </cc1:ComboBox>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Button ID="Button1" runat="server" BackColor="#FFFBFF" 
                    BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" 
                    Font-Names="Verdana" Font-Size="Small" ForeColor="#284775" 
                    onclick="Button1_Click" Text="GO" Width="76px" />
                
            </asp:Panel>
            </td>
    </tr>
    <tr>
        <td valign="top">
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                <ContentTemplate>
                                    <asp:Label ID="ErrorLabel" runat="server" BackColor="#FFFFCC" 
                                ForeColor="Maroon" Height="24px" 
                                Text="Error: The entity can't be deleted from the following reason: This entity is a FK of other entity." 
                                Visible="False"></asp:Label>
                                    <asp:DetailsView ID="ComponentDetailsView" runat="server" AllowPaging="True" 
                                        AutoGenerateRows="False" CellPadding="4" 
                                        DataKeyNames="component_num" DataSourceID="ComponentDataSource" 
                                        ForeColor="#333333" GridLines="None" Height="50px" 
                                        ondatabound="ComponentDetailsView_DataBound" 
                                        onitemcommand="ComponentDetailsView_ItemCommand" 
                                        onitemdeleting="ComponentDetailsView_ItemDeleting" Width="540px">
                                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
                                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                        <Fields>
                                            <asp:BoundField DataField="component_num" HeaderText="Number" ReadOnly="True" 
                                                SortExpression="component_num" Visible="False" />
                                            <asp:TemplateField HeaderText="Component Serial Number" 
                                                SortExpression="component_serial_num">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="SNTextBox" runat="server" 
                                                        Text='<%# Bind("component_serial_num") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                                        ControlToValidate="SNTextBox" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:CustomValidator ID="CustomValidator1" runat="server" 
                                                        ControlToValidate="SNTextBox" ErrorMessage="Already Exist" 
                                                        onservervalidate="CustomValidator1_ServerValidate1"></asp:CustomValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox1" runat="server" 
                                                        Text='<%# Bind("component_serial_num") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="ComponentLabel" runat="server" 
                                                        Text='<%# Bind("component_serial_num") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="component_description" HeaderText="Description" 
                                                SortExpression="component_description" />
                                            <asp:BoundField DataField="component_place" HeaderText="Place" 
                                                SortExpression="component_place" />
                                            <asp:TemplateField HeaderText="Quantity" SortExpression="component_quantity">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="TextBox2" runat="server" 
                                                        Text='<%# Bind("component_quantity") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                                        ControlToValidate="TextBox2" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:RangeValidator ID="RangeValidator1" runat="server" 
                                                        ControlToValidate="TextBox2" ErrorMessage="Value Range [0,1M]" 
                                                        MaximumValue="10000000" MinimumValue="0" Type="Integer"></asp:RangeValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox2" runat="server" 
                                                        Text='<%# Bind("component_quantity") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("component_quantity") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Vendor" SortExpression="component_vendor">
                                                <EditItemTemplate>
                                                    <cc1:ComboBox ID="ComboBox2" runat="server" AppendDataBoundItems="True" 
                                                        AutoCompleteMode="Append" DataSourceID="VendorObjectDataSource2" 
                                                        DataTextField="vendor_name" DataValueField="vendor_num" 
                                                        DropDownStyle="DropDownList" MaxLength="0" 
                                                        SelectedValue='<%# Bind("component_vendor") %>' style="display: inline;">
                                                    </cc1:ComboBox>
                                                    <asp:ObjectDataSource ID="VendorObjectDataSource2" runat="server" 
                                                        SelectMethod="VendorGet" TypeName="WarehouseWebAPP.code.BLL.VendorBLL">
                                                    </asp:ObjectDataSource>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:DropDownList ID="DropDownList5" runat="server" 
                                                        DataSourceID="VendorObjectDataSource3" DataTextField="vendor_name" 
                                                        DataValueField="vendor_num" SelectedValue='<%# Bind("component_vendor") %>'>
                                                    </asp:DropDownList>
                                                    <asp:ObjectDataSource ID="VendorObjectDataSource3" runat="server" 
                                                        SelectMethod="VendorGet" TypeName="WarehouseWebAPP.code.BLL.VendorBLL">
                                                    </asp:ObjectDataSource>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="VendorLabel" runat="server" 
                                                        Text='<%# Bind("component_vendor") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Supplier" SortExpression="component_supplier">
                                                <EditItemTemplate>
                                                    <cc1:ComboBox ID="ComboBox3" runat="server" AppendDataBoundItems="True" 
                                                        AutoCompleteMode="Append" DataSourceID="SupplierObjectDataSource" 
                                                        DataTextField="supplier_name" DataValueField="supplier_num" 
                                                        DropDownStyle="DropDownList" MaxLength="0" 
                                                        SelectedValue='<%# Bind("component_supplier") %>' style="display: inline;">
                                                    </cc1:ComboBox>
                                                    <asp:ObjectDataSource ID="SupplierObjectDataSource" runat="server" 
                                                        SelectMethod="SupplierGet" TypeName="WarehouseWebAPP.code.BLL.SupplierBLL">
                                                    </asp:ObjectDataSource>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="SupplierLabel" runat="server" 
                                                        Text='<%# Bind("component_supplier") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                                            <asp:ButtonField CommandName="MailComponent" Text="Mail Component" />
                                        </Fields>
                                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <EditRowStyle BackColor="#999999" />
                                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                    </asp:DetailsView>
                                    <br />
                                    <asp:Panel ID="MailPanel1" runat="server" BorderStyle="Groove" 
                                        CssClass="style33" Height="332px" Visible="False" ForeColor="Black">
                                        <br />
                                        <asp:RadioButton ID="SupplierRadioButton" runat="server" Checked="True" 
                                            GroupName="Group1" Text="Send This Component to it's Supplier" />
                                        <br />
                                        <asp:RadioButton ID="CustomerRadioButton" runat="server" GroupName="Group1" 
                                            Text="Send This Component to the following Customer " />
                                        <cc1:ComboBox ID="CustomerComboBox" runat="server" AppendDataBoundItems="True" 
                                            AutoCompleteMode="Append" DataSourceID="CustomerObjectDataSource" 
                                            DataTextField="customer_name" DataValueField="customer_num" 
                                            DropDownStyle="DropDownList" MaxLength="0" style="display: inline;">
                                        </cc1:ComboBox>
                                        <br />
                                        <br />
                                        Add Notes:<br />
                                        <asp:TextBox ID="NotesTextBox" runat="server" Height="158px" 
                                            TextMode="MultiLine" Width="629px" BorderStyle="Groove" ForeColor="Black"></asp:TextBox>
                                        <br />
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                                        &nbsp;
                                        <asp:Button ID="SendButton" runat="server" BackColor="#FFFBFF" 
                                            BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" 
                                            Font-Names="Verdana" Font-Size="Small" ForeColor="#284775" Height="25px" 
                                            onclick="SendButton_Click" style="text-align: center" Text="Send Mail" 
                                            Width="99px" />
                                    </asp:Panel>
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
                                    <asp:AsyncPostBackTrigger ControlID="SendButton" EventName="Click" />
                                </Triggers>
                            </asp:UpdatePanel>

            <asp:ObjectDataSource ID="CustomerObjectDataSource" runat="server" 
                SelectMethod="CustomerGet" TypeName="WarehouseWebAPP.code.BLL.CustomerBLL">
            </asp:ObjectDataSource>
            <asp:ObjectDataSource ID="ComponentDataSource" runat="server" 
                    SelectMethod="ComponentGetBySN" 
                    TypeName="WarehouseWebAPP.code.BLL.ComponentBLL" 
                UpdateMethod="ComponentUpdate" 
                OldValuesParameterFormatString="original_{0}" 
                DeleteMethod="ComponentDelete">
                <UpdateParameters>
                    <asp:Parameter Name="component_serial_num" Type="String" />
                    <asp:Parameter DbType="Guid" Name="component_vendor" />
                    <asp:Parameter Name="component_description" Type="String" />
                    <asp:Parameter Name="component_place" Type="String" />
                    <asp:Parameter Name="component_quantity" Type="Int32" />
                    <asp:Parameter DbType="Guid" Name="component_supplier" />
                    <asp:Parameter DbType="Guid" Name="original_component_num" />
                </UpdateParameters>
                <SelectParameters>
                    <asp:ControlParameter ControlID="ComboBox1" DefaultValue="%" 
                            Name="component_serial_num" PropertyName="SelectedValue" 
                        Type="String" />
                </SelectParameters>
            </asp:ObjectDataSource>
            <asp:ObjectDataSource ID="comboObjectDataSource" runat="server" 
                SelectMethod="ComponentGetData" 
                TypeName="WarehouseWebAPP.code.BLL.ComponentBLL"></asp:ObjectDataSource>
            <asp:ObjectDataSource ID="CustomerObjectDataSource0" runat="server" 
                SelectMethod="CustomerGet" TypeName="WarehouseWebAPP.code.BLL.CustomerBLL">
            </asp:ObjectDataSource>
        </td>
    </tr>
    <tr>
        <td align="left">

            &nbsp;</td>
    </tr>
    </table>
</asp:Content>
